<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <h:body>
        <ui:composition template="templateGeneral.xhtml">
            <ui:define name="title">Obavestenja</ui:define>
            <ui:define name="center">

                <h:form id="obavForm" enctype="multipart/form-data">

                    <p:growl id="infoMessage" sticky="false"/>

                    <p:tabView id="obavestenja" dynamic="true" orientation="left" effect="fold">
                        <p:tab title="Dodaj obavestenje">

                            <h:panelGrid id="dodaj" columns="1">
                                <p:selectOneMenu value="#{obvsCtrl.selectedPredmetString}">  
                                    <p:ajax event="change" update=":obavForm:obavestenja:dodaj" listener="#{obvsCtrl.onChangePredmet}" />
                                    <f:selectItem itemLabel="Odaberi" itemValue="" />  
                                    <f:selectItems value="#{obvsCtrl.predmetiList}" />  
                                </p:selectOneMenu>
                                <h:outputText value="Naslov" style="font-weight: bold"/>
                                <p:inputText value="#{obvsCtrl.novoObavestenje.naslov}"/>
                                <h:outputText value="" style="font-weight: bold"/>
                                <p:editor id="editor" value="#{obvsCtrl.novoObavestenje.tekst}" width="600"/> 
                                <h:outputText value="Datum" style="font-weight: bold"/>
                                <p:calendar value="#{obvsCtrl.novoObavestenje.datum}" id="popupCal" />
                                <p:selectOneMenu value="#{obvsCtrl.kategorija}">  
                                    <f:selectItem itemLabel="Odaberi" itemValue="" />  
                                    <f:selectItems value="#{obvsCtrl.kategorije}" />  
                                </p:selectOneMenu>
                                <p:fileUpload fileUploadListener="#{obvsCtrl.uploadHandler}" mode="advanced" multiple="true" /> 
                                <p:commandButton value="Snimi" ajax="false" actionListener="#{obvsCtrl.snimiObavestenje}"/>
                            </h:panelGrid> 
                        </p:tab>

                        <p:tab title="Azuriraj postojeca obavestenja">
                            <p:selectOneMenu value="#{obvsCtrl.selectedPredmetString}" style="min-width: 360px">  
                                <p:ajax event="change" update=":obavForm:obavestenja:aaa" listener="#{obvsCtrl.onChangePredmet()}" />
                                <f:selectItem itemLabel="Odaberi predmet" itemValue="" />  
                                <f:selectItems value="#{obvsCtrl.predmetiList}" />  
                            </p:selectOneMenu>
                            <p:selectOneMenu id="aaa" value="#{obvsCtrl.selectedObavestenjeString}" style="min-width: 360px; margin-left: 30px">  
                                <p:ajax event="change" update=":obavForm:obavestenja:azuriraj" listener="#{obvsCtrl.onChangeObavestenje}" />
                                <f:selectItem itemLabel="Odaberi obavestenje" itemValue="" />  
                                <f:selectItems value="#{obvsCtrl.obavestenjaList}" />  
                            </p:selectOneMenu>  
                            <h:panelGrid id="azuriraj" columns="2" cellpadding="10">
                                <h:outputText value="Naslov" style="font-weight: bold"/>
                                <p:inputText id="naslov" value="#{obvsCtrl.selectedObavestenje.naslov}" />
                                <h:outputText value="" style="font-weight: bold"/>
                                <p:editor  value="#{obvsCtrl.selectedObavestenje.tekst}" width="600"/>  
                                <h:outputText value="Datum" style="font-weight: bold"/>
                                <p:calendar value="#{obvsCtrl.selectedObavestenje.datum}"  />
                                <p:fileUpload fileUploadListener="#{obvsCtrl.uploadHandler}" mode="advanced" multiple="true" /> 
                                <h:outputText value=""/>
                                <p:commandButton value="Snimi" actionListener="#{obvsCtrl.azurirajObavestenje}"/>
                                <p:commandButton value="Obrisi" actionListener="#{obvsCtrl.obrisiObavestenje}"/>
                            </h:panelGrid>
                        </p:tab>
                    </p:tabView>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

